const articleModel = require("../models/articleModel.js")

class Article {
    publish(title, user_id, cate, cate_name, content, src, tag, status) {
        const date = new Date()
        const d = date.toLocaleDateString()
        const t = date.toLocaleTimeString()
        const createAt = d + " " + t
        return articleModel.publish(title, user_id, cate, cate_name, content, src, tag, createAt, status)
    }

    remove(id) {
        return articleModel.remove(id)
    }

    items(page_num, page_size) {
        return articleModel.items(page_num, page_size)
    }

    modify(title, user_id, cate, cate_name, content, src, tag, id, status, is_top) {
        return articleModel.modify(title, user_id, cate, cate_name, content, src, tag, id, status, is_top)
    }

    search(keyword) {
        return articleModel.search(keyword)
    }

    detail(id) {
        return articleModel.detail(id)
    }

    updateArticlesByCate(parentCate) {
        return articleModel.updateArticlesByCate(parentCate)
    }

    getHotArticles(limit) {
        return articleModel.getHotArticles(limit)
    }

    list(page_num, page_size, cate_name) {
        return articleModel.list(page_num, page_size, cate_name)
    }
}

module.exports = Article;